/*
 * @FilePath: /tads/server/app/business/service/dto/bus.go
 * @Author: wnina0x0
 * @Date: 2025-04-15 15:00:17
 * @Description:
 *
 * 版权信息 : 2025 by wnina0x0, All Rights Reserved.
 */
package dto

import (
	"tads/server/app/business/models"
)

type BusGetRequests struct {
	GetPage
	BusTypeName string `form:"bus_type_name"`
}

type BusInsetRequests struct {
	BusTypeName string `json:"bus_type_name"`
	BusTypeDesc string `json:"bus_type_desc"`
}

func (b *BusInsetRequests) Generate(models *models.BusType) {
	models.BusTypeName = b.BusTypeName
	models.BusTypeDesc = b.BusTypeDesc
}

type BusUpdateRequests struct {
	ID          uint   `json:"id"`
	BusTypeName string `json:"bus_type_name"`
	BusTypeDesc string `json:"bus_type_desc"`
}

func (s *BusUpdateRequests) Generate(models *models.BusType) {
	models.BusTypeName = s.BusTypeName
	models.BusTypeDesc = s.BusTypeDesc
}

type BusStatusRequests struct {
	ID     uint `json:"id"`
	Status bool `json:"status"`
}
type BusGetResponse struct {
	Total       int              `json:"total"`        // 总记录数
	TotalPages  int              `json:"total_pages"`  // 总页数
	CurrentPage int              `json:"current_page"` // 当前页
	PageSize    int              `json:"page_size"`    // 每页数量
	Data        []models.BusType `json:"data"`         // 实际数据
}

func (p *BusGetResponse) NewPageResponse(total int, req *BusGetRequests, data []models.BusType) *BusGetResponse {
	totalPages := total / req.PageSize
	if total%req.PageSize > 0 {
		totalPages++
	}

	return &BusGetResponse{
		Total:       total,
		TotalPages:  totalPages,
		CurrentPage: req.PageIndex,
		PageSize:    req.PageSize,
		Data:        data,
	}
}
